#coding=utf-8
from types import *
from feeds import feedtype
from feeds.feedtype import *
from django.core.cache import cache

PAGE_SIZE           = 10                                             # Size per page to show
FEED_SIZE           = 10                                             # Output feed items size per user
UPDATE_INTERVAL     = 1800                                           # Update feeds interval seconds
PROCESS_POOL_MAX    = 20
FEED_TYPE_LIST      = cache.get("FEED_TYPE_LIST")                 #Feed type list

#FEED_TYPE_LIST      = [                                             # Feed type list
#                        'Douban',
#                        'Fanfou',
#                        'Blog'
#                      ]

if not FEED_TYPE_LIST:
    FEED_TYPE_LIST = []
    
    def getList(element):
        if element[0:2] == '__':
            return
        else:
            exec("if (type(%s) == ClassType) and (BaseFeedType in %s.__bases__):FEED_TYPE_LIST.append(element)" % (element, element))
    
    
    filter(getList, dir(feedtype))
    cache.set("FEED_TYPE_LIST", FEED_TYPE_LIST)
    
FEED_FACTORY_DICT   = cache.get("FEED_FACTORY_DICT")              #FeedFactory list

if FEED_FACTORY_DICT is None:
    from feeds.feedfactory import FeedFactory
    
    FEED_FACTORY_DICT = {}
    for type in FEED_TYPE_LIST:
        FEED_FACTORY_DICT[type] = FeedFactory.createInstance(type)
    
    cache.set("FEED_FACTORY_DICT", FEED_FACTORY_DICT)
